﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WenSkin.Forms
{
    public partial class WenBottomInfoForm : WenForm
    {
        public WenBottomInfoForm() : base()
        {
            InitializeComponent();
            RefreshPadding();
        }
        private int bottomWidth = 30;
        private string bottomText;

        [Category("Wen")]
        [Description("底部信息栏大小")]
        [RefreshProperties(RefreshProperties.All)]
        public int BottomWidth
        {
            get => bottomWidth;
            set
            {
                bottomWidth = value;
                RefreshPadding();
            }
        }
        [Category("Wen")]
        [Description("底部信息栏显示内容")]
        [RefreshProperties(RefreshProperties.All)]
        public string BottomText
        {
            get => bottomText;
            set
            {
                bottomText = value;
                RefreshPadding();
            }
        }

        protected override void RefreshPadding()
        {
            this.Padding = new Padding() { Top = TitleHeight, Left = FrameWidth, Bottom = bottomWidth, Right = FrameWidth };
            this.Invalidate();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;
            DrawBottomInfo(g);
        }


        private void DrawBottomInfo(Graphics g)
        {
            Brush b = new SolidBrush(FrameColor);
            g.FillRectangle(b, 0, this.Height - BottomWidth, this.Width, BottomWidth);

            //绘制底部信息
            _ = TextRenderer.MeasureText(bottomText, this.Font).Width;

            Rectangle rec = new Rectangle(0, this.Height - BottomWidth, this.Width, BottomWidth);
            Rectangle recStr = new Rectangle(10, rec.Y, rec.Width - 20, rec.Height);

            g.DrawString(bottomText, this.Font, new SolidBrush(this.ForeColor), recStr,
                new StringFormat(StringFormatFlags.NoClip | StringFormatFlags.NoWrap)
                {
                    LineAlignment = StringAlignment.Center,
                    Alignment = StringAlignment.Far,
                    Trimming = StringTrimming.EllipsisCharacter
                });
        }

    }
}
